import java.awt.BorderLayout;
import java.awt.GridLayout;
import javax.swing.*;


public class MainGUI {
	public MainGUI()
	{
		JPanel loginPane = createPaneLOGIN();
		displayPane ("Log In", loginPane, false);
		
		JPanel studentPane = createPaneSTUDENT();
		displayPane("Student Main Page", studentPane, true);
	}
	
	/*
	 * main page for students, display schedule
	 */
	private JPanel createPaneSTUDENT()
	{
		// order: Center, N,S,W (East DNE)
		
		// Center - display schedule panel
		JPanel scheduleDisplayPane = new JPanel();

		// North - greeting, save/load, help, logout
		JPanel accountPane = new JPanel(new GridLayout(1,2));
		// greeting
		JPanel greetingPane = new JPanel();
		// buttons - save load help logout
		JButton saveButton = new JButton("Save");
		JButton loadButton = new JButton("Load");
		JButton helpButton = new JButton("Help");
		JButton exitButton = new JButton("Log Out");
		//
		JPanel accountButtonPane = new JPanel(new GridLayout(1,4));
		accountButtonPane.add(saveButton);
		accountButtonPane.add(loadButton);
		accountButtonPane.add(helpButton);
		accountButtonPane.add(exitButton);
		//
		accountPane.add(greetingPane);
		accountPane.add(accountButtonPane);
			
		// South - feedback panel
		JPanel feedbackPane = new JPanel();
		JLabel feedbackLabel = new JLabel("Feedback:");
		JTextArea feedbackArea = new JTextArea("Good so far-- blankity");
		feedbackPane.add(feedbackLabel);
		feedbackPane.add(feedbackArea);
		
		// WEST - add/edit course, audit report panel
		JPanel scheduleButtonPane = new JPanel(new GridLayout(3,1));
		JButton addCourseButton		= new JButton("Add Course");
		JButton editCourseButton	= new JButton("Edit Course");
		JButton auditButton			= new JButton("Audit Report");
		scheduleButtonPane.add(addCourseButton);
		scheduleButtonPane.add(editCourseButton);
		scheduleButtonPane.add(auditButton);
		
		// put everything together
		JPanel mainStuPane = new JPanel(new BorderLayout());
		mainStuPane.add(scheduleDisplayPane,	BorderLayout.CENTER);
		mainStuPane.add(accountPane, 			BorderLayout.NORTH);
		mainStuPane.add(scheduleButtonPane, 	BorderLayout.WEST);
		mainStuPane.add(feedbackPane,			BorderLayout.SOUTH);
		
		return mainStuPane;
	}
	
	/*
	 * create login screen
	 * - ADD MEANING TO BUTTONS: LOGIN / REGISTER
	 */
	private JPanel createPaneLOGIN()
	{
		// query username
		JPanel usernamePane			= new JPanel (new GridLayout(1,2));
		JLabel usernameLabel		= new JLabel ("Username:");
		JTextField usernameField	= new JTextField(10);
		usernamePane.add(usernameLabel);
		usernamePane.add(usernameField);
		
		// query password
		JPanel passwordPane			= new JPanel(new GridLayout(1,2));
		JLabel passwordLabel		= new JLabel ("Password:");
		JPasswordField passwordField = new JPasswordField(10);
		passwordPane.add(passwordLabel);
		passwordPane.add(passwordField);
		
		// buttons
		JButton registerButton		= new JButton ("Register");
		JButton loginButton			= new JButton ("Log In");
		JPanel	buttonPane			= new JPanel();
		buttonPane.add(registerButton);
		buttonPane.add(loginButton);
		
		// add meaning to buttons
		//
		//
		//
		
		//----- put it all together
		JPanel loginPane			= new JPanel(new GridLayout(3,1));
		loginPane.add(usernamePane);
		loginPane.add(passwordPane);
		loginPane.add(buttonPane);
		
		// return it
		return loginPane;
	}

	/*
	 * display the pane
	 * exit on close - exit out of program if the frame is exited out of
	 */
	private void displayPane (String title, JPanel pane, boolean exitOnClose)
	{
		JFrame frame = new JFrame(title);
		frame.add(pane);
		frame.pack();
		frame.setVisible(true);
		
		if(exitOnClose)
			frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
}
